import { defineStore } from 'pinia'
import type { ICommonState } from './type'
import { postEntireRolesApi } from '@/service/api'

const useCommonStore = defineStore('common', {
  state: (): ICommonState => ({
    entireRoles: [],
    isShowModel:false
  }),
  actions: {
     fetchEntireDataAction(pageNumber?:number,pageSize?:number,status?:number) {
      return new Promise<any>((resolve, reject) => {
        postEntireRolesApi({
          pageNumber:pageNumber,
          pageSize:pageSize,
          status:status
        }).then(res => {
          this.entireRoles =res.result.list
          resolve(res)
        })
        .catch(err => {
          reject(err)
        })
      })
    },
  },
  
  persist: {
    paths: ['entireRoles']
  }
})

export default useCommonStore
